package com.ruoyi.web.controller.compensationManagement;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.compensationManagement.domain.CompensationDeductionAmountSettings;
import com.ruoyi.compensationManagement.service.ICompensationDeductionAmountSettingsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 扣款金额设置Controller
 * 
 * @author ruoyi
 * @date 2022-10-05
 */
@RestController
@RequestMapping("/compensationManagement/deductionAmountSettings")
public class CompensationDeductionAmountSettingsController extends BaseController
{
    @Autowired
    private ICompensationDeductionAmountSettingsService compensationDeductionAmountSettingsService;

    /**
     * 查询扣款金额设置列表
     */
    @PreAuthorize("@ss.hasPermi('compensationManagement:deductionAmountSettings:list')")
    @GetMapping("/list")
    public TableDataInfo list(CompensationDeductionAmountSettings compensationDeductionAmountSettings)
    {
        startPage();
        List<CompensationDeductionAmountSettings> list = compensationDeductionAmountSettingsService.selectCompensationDeductionAmountSettingsList(compensationDeductionAmountSettings);
        return getDataTable(list);
    }

    /**
     * 导出扣款金额设置列表
     */
    @PreAuthorize("@ss.hasPermi('compensationManagement:deductionAmountSettings:export')")
    @Log(title = "扣款金额设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CompensationDeductionAmountSettings compensationDeductionAmountSettings)
    {
        List<CompensationDeductionAmountSettings> list = compensationDeductionAmountSettingsService.selectCompensationDeductionAmountSettingsList(compensationDeductionAmountSettings);
        ExcelUtil<CompensationDeductionAmountSettings> util = new ExcelUtil<CompensationDeductionAmountSettings>(CompensationDeductionAmountSettings.class);
        util.exportExcel(response, list, "扣款金额设置数据");
    }

    /**
     * 获取扣款金额设置详细信息
     */
    @PreAuthorize("@ss.hasPermi('compensationManagement:deductionAmountSettings:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(compensationDeductionAmountSettingsService.selectCompensationDeductionAmountSettingsById(id));
    }

    /**
     * 新增扣款金额设置
     */
    @PreAuthorize("@ss.hasPermi('compensationManagement:deductionAmountSettings:add')")
    @Log(title = "扣款金额设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CompensationDeductionAmountSettings compensationDeductionAmountSettings)
    {
        return toAjax(compensationDeductionAmountSettingsService.insertCompensationDeductionAmountSettings(compensationDeductionAmountSettings));
    }

    /**
     * 修改扣款金额设置
     */
    @PreAuthorize("@ss.hasPermi('compensationManagement:deductionAmountSettings:edit')")
    @Log(title = "扣款金额设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CompensationDeductionAmountSettings compensationDeductionAmountSettings)
    {
        return toAjax(compensationDeductionAmountSettingsService.updateCompensationDeductionAmountSettings(compensationDeductionAmountSettings));
    }

    /**
     * 删除扣款金额设置
     */
    @PreAuthorize("@ss.hasPermi('compensationManagement:deductionAmountSettings:remove')")
    @Log(title = "扣款金额设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(compensationDeductionAmountSettingsService.deleteCompensationDeductionAmountSettingsByIds(ids));
    }
}
